<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@ page import="com.fengke.portal.config.HostConfig" %>
<%
	HostConfig hostConfig = (HostConfig) request.getSession().getServletContext().getAttribute("hostConfig");
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=hostConfig.getPortalHost() %>" />
<title>
	<s:if test='productVO.productModel.name != null && !"".equals(productVO.productModel.name.trim())'>
		生成订单-<s:property value="productVO.productModel.name" />
	</s:if>
	<s:else><%=hostConfig.getWebSiteName() %></s:else>
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1, maximum-scale=1, user-scalable=no">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link href="resources/travel/weixin/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="resources/travel/weixin/css/bootstrap-theme.css" rel="stylesheet" media="screen">
<link href="resources/travel/weixin/css/font-awesome.min.css" rel="stylesheet" media="screen">
<link href="resources/travel/weixin/css/messenger.css" rel="stylesheet" media="screen">
<link href="resources/travel/weixin/css/image.css" rel="stylesheet" media="screen">
<link href="resources/travel/weixin/css/travel.css" rel="stylesheet" media="screen">
<link href="resources/travel/weixin/jslib/icheck/skins/flat/blue.css" rel="stylesheet" media="screen">
<link href="resources/travel/weixin/jslib/jquery-validation-engine/css/validationEngine.jquery.css" rel="stylesheet" media="screen">
<link href="resources/travel/weixin/jslib/mobiscroll-calendar/css/mobiscroll.custom-2.14.4.min.css" rel="stylesheet" media="screen">

<script src="resources/travel/weixin/js/jquery.min.js"></script>
<script src="resources/travel/weixin/js/bootstrap.min.js"></script>
<script src="resources/travel/weixin/js/bootbox.js"></script>
<script src="resources/travel/weixin/js/messenger.js"></script>
<script src="resources/travel/weixin/js/messenger-theme-future.js"></script>
<script src="resources/travel/weixin/js/holder.js"></script>

<script src="resources/travel/weixin/jslib/icheck/js/jquery.icheck.min.js"></script>
<script src="resources/travel/weixin/jslib/jquery-validation-engine/js/languages/jquery.validationEngine-zh_CN.js"></script>
<script src="resources/travel/weixin/jslib/jquery-validation-engine/js/jquery.validationEngine.js"></script>
<script src="resources/travel/weixin/jslib/mobiscroll-calendar/js/mobiscroll.custom-2.14.4.min.js"></script>
<script src="resources/travel/weixin/js/application.js"></script>
<script type="text/javascript" src="resources/shop/js/common.js"></script>

<style>
a:hover {
	text-decoration:none;
}
a:link {
	text-decoration:none;
}
</style>
<style type="text/css" id="holderjs-style"></style>
</head>
<body >

<div class="container overflow-x" id="orderMain">
  <div class="row">
   <div class="col-xs-12 col-sm-12 padding_0 order">
     <div class="header_title">
      <h4><s:property value="productVO.productModel.name" /></h4>
      <p class="channel"><s:property value="productVO.productModel.startAddress"/>-<s:property value="productVO.productModelproduct.destination"/></p>
<!--       <div class="back_ico"><a class="inner-back" href="detail.htm"></a></div>
 -->      <div class="usercenter_ico" onClick="goUserIndex()"><a href="weixin/user/index.html" class="usercenter-back"></a></div>
      </div> </div>
  </div>
  
  <div class="row">
    <div class="col-xs-12 col-sm-12 padding_0 order_list">
      <div class="panel-group acc-v1 margin-bottom-0 " id="accordion-1">
        <div class="panel panel-default margin-bottom-10">
          <div class="panel-heading" id="starting_date">
	          <h4 class="panel-title clearfix pointer" > 
		          <span class="glyphicon glyphicon_calendar glyphicon_size pull-left"></span>
		          <span class="pull-left itineraryfonts" >选择出行日期</span>
		          <span class="pull-left itineraryfonts" id="date_content">
		          	<s:if test='orderVO != null && orderVO.orderModel != null && orderVO.orderModel.goDateString != null && !"".equals(orderVO.orderModel.goDateString)'>
		          		<s:property value="orderVO.orderModel.goDateString" />
		          	</s:if>
		          	<s:else>
		          		<s:property value="productVO.productModel.defaultDateString" />
		          	</s:else>
		          </span>
		          <span class="bluearrow  bluerightarrow pull-right"></span> 
	          </h4>
          </div>
        </div>
        <s:if test='productVO.productModel.hoursePrice != null && productVO.productModel.hoursePrice != 0'>
         <div class="panel panel-default margin-bottom-10" >
          <div class="panel-heading ">
            <h4 class="panel-title clearfix"> <a class="accordion-toggle clearfix "  > 
            <span class=" pull-left  position_reative">
              <div class="pull-left" onclick="choose(this,0)">
	            <span class=" pull-left  position_reative">
	              <div class="icheckbox_polaris <s:if test='orderVO != null && orderVO.orderModel != null && !orderVO.orderModel.isShareHouse'></s:if><s:else>checked</s:else>" id="share_house">
	                <input type="checkbox"  tabindex="22" style="position: absolute; top: 10%; left: 10%; display: block; width: 80%; height: 80%; margin: 0px; padding: 0px; background: none repeat scroll 0% 0% rgb(255, 255, 255); border: 0px none; opacity: 0;">
	                <ins style="position: absolute; top: 10%; left: 10%; display: block; width: 80%; height: 80%; margin: 0px; padding: 0px; background: none repeat scroll 0% 0% rgb(255, 255, 255); border: 0px none; opacity: 0;"></ins></div>
	              </span><span class="pull-left itineraryfonts ml_42" >同意拼房</span>
              </div>
              
              <div class="pull-left polarisNone" onclick="choose(this,1)">
	              <span class=" pull-left  position_reative" >
	              <div class="icheckbox_polaris <s:if test='orderVO != null && orderVO.orderModel != null && !orderVO.orderModel.isShareHouse'></s:if><s:else>checked</s:else>">
	                <input type="checkbox"  tabindex="22" style="position: absolute; top: 10%; left: 10%; display: block; width: 80%; height: 80%; margin: 0px; padding: 0px; background: none repeat scroll 0% 0% rgb(255, 255, 255); border: 0px none; opacity: 0;">
	                <ins style="position: absolute; top: 10%; left: 10%; display: block; width: 80%; height: 80%; margin: 0px; padding: 0px; background: none repeat scroll 0% 0% rgb(255, 255, 255); border: 0px none; opacity: 0;"></ins></div>
	              </span><span class="pull-left itineraryfonts ml_42" >不拼房</span>
              </div>
            </h4>
          </div>
          
           <div  class="panel-collapse collapse in">
		   <div class="panel-body panel-body-bj">
		  	<div class="row">
                <div class="col-xs-12 itinerary_show">
                  <p class="safe" id="agreement">
                    <s:if test='orderVO != null && orderVO.orderModel != null && !orderVO.orderModel.isShareHouse'>
                    	需要补单房差 <s:property value="productVO.productModel.hoursePrice" />元，如需加床或转为三人间请致电：<i><a href="tel:<s:property value='productVO.productModel.phone' />"><s:property value='productVO.productModel.phone' /></a></i>
                    </s:if>
                    <s:else>根据实际情况，也有可能实在没法拼房，届时仍需补单房差，但我们将努力不让你多花钱。</s:else>
                  </p>
                </div>
              </div>
		   </div>
		  </div>
        </div>
        </s:if>
        <div class="panel panel-default margin-bottom-10">
          <div class="panel-heading collapseDiv" onclick="$(this).next().collapse('toggle')">
            <h4 class="panel-title clearfix"> 
	            <a class="accordion-toggle clearfix"  >
		            <span class="glyphicon glyphicon_peoples glyphicon_size pull-left" ></span>
		            <span class="pull-left itineraryfonts">选择人数</span>
		            <span class="bluearrow  bluedownarrow pull-right"></span>
	            </a>
            </h4>
          </div>
          <div class="panel-collapse collapse in">
            <div class="panel-body">
            <form id="collapse-One">
              <div class="row">
                <div class="col-xs-12 itinerary_show">
                  <h4 class="panel-title clearfix"> 
	                  <a class="accordion-toggle clearfix pull-left order_people"  >
		                  <span class="glyphicon glyphicon_peoples glyphicon_size pull-left" ></span>
		                  <span class="pull-left itineraryfonts text-indent">成人</span>
		                  <span class="pull-left itineraryfonts color_orange">
		                  	<s:text name="format.number">
								<s:param value="productVO.productModel.price"/>
							</s:text>
		                  </span>
	                  </a>
		              <div class="ace-spinner middle touch-spinner pull-left" style="width:40%">
		                <div class="input-group form-group">
		                  <div class="spinbox-buttons input-group-btn" onclick="downOne(this)">
		                    <button class="btn  btn_blue" type="button"><span class="glyphicon glyphicon-minus"></span></button>
		                  </div>
	                  		<input type="text" id="adultNum"  disabled="disabled" class="validate[required,custom[integer],min[1]] input-mini spinbox-input form-control input_numberbox text-center" value="<s:if test='orderVO.orderModel.adultNum != null'><s:property value='orderVO.orderModel.adultNum' /></s:if><s:else>1</s:else>" data-prompt-position="topLeft:10">
		                  <div class="spinbox-buttons input-group-btn" onclick="addOne(this)">
		                    <button class="btn  btn_blue" type="button"><span class="glyphicon glyphicon-plus"></span></button>
		                  </div>
		                </div>
		              </div>
           		 </h4>
                </div>
              </div>
              <s:if test='productVO.productModel.childrenPrice != null && productVO.productModel.childrenPrice != 0'>
              <div class="row">
                <div class="col-xs-12 itinerary_show">
                  <h4 class="panel-title clearfix"> 
                  <a class="accordion-toggle clearfix pull-left order_people"  >
	                  <span class="glyphicon glyphicon_peoples glyphicon_size pull-left" ></span>
	                  <span class="pull-left itineraryfonts text-indent">儿童</span>
	                  <span class="pull-left itineraryfonts color_orange">
	                  	<s:text name="format.number">
							<s:param value="productVO.productModel.childrenPrice"/>
						</s:text>
	                  </span>
                  </a>
	              <div class="ace-spinner middle touch-spinner pull-left" style="width:40%">
	                <div class="input-group form-group">
	                  <div class="spinbox-buttons input-group-btn" onclick="downOne(this)">
	                    <button class="btn  btn_blue" type="button"><span class="glyphicon glyphicon-minus"></span></button>
	                  </div>
	                  <input type="text"  id="childrenNum" disabled="disabled" class="input-mini spinbox-input form-control input_numberbox text-center validate[required,custom[integer],min[0]]" value="<s:if test='orderVO.orderModel.childrenNum != null'><s:property value='orderVO.orderModel.childrenNum' /></s:if><s:else>0</s:else>" data-prompt-position="topLeft:10">
	                  <div class="spinbox-buttons input-group-btn" onclick="addOne(this)">
	                    <button class="btn  btn_blue" type="button"><span class="glyphicon glyphicon-plus"></span></button>
	                  </div>
	                </div>
	              </div>
           		</h4>
                </div>
              </div>
              </s:if>
              <s:else>
              	  <input type="hidden"  id="childrenNum"  class="input-mini spinbox-input form-control input_numberbox text-center validate[required,custom[integer],min[0]]" value="<s:if test='orderVO.orderModel.childrenNum != null'><s:property value='orderVO.orderModel.childrenNum' /></s:if><s:else>0</s:else>" data-prompt-position="topLeft:10">
              </s:else>
              </form>
            </div>
          </div>
        </div>
       
        
         <!-- <div class="panel panel-default  margin-bottom-10" >
          <div class="panel-heading">
            <h4 class="panel-title clearfix"><span class="glyphicon glyphicon_peoples glyphicon_size pull-left" ></span><span class="pull-left itineraryfonts">添加<i class="color_orange" id="memberNum"> [#if order??]${order.totalNum}[#else]1[/#if]</i> 位成员信息</span><a href="#" onclick="addMember()"><span class="pull-right date" style="position:relative"><span class="glyphicon glyphicon_add glyphicon_size"></span></span></a> </h4>
          </div>
        </div> -->
        
        <div id="memberInfo" class="panel panel-default  margin-bottom-10" style="overflow:visible">
          <div class="panel-heading "  <s:if test='orderVO.orderModel != null && orderVO.orderItemModelList != null && orderVO.orderItemModelList.size() == orderVO.orderModel.totalNum'>onclick="$(this).next().collapse('toggle')"</s:if> id="member_div">
            <h4 class="panel-title clearfix">
            <span class="glyphicon glyphicon_news glyphicon_size pull-left" ></span>
            <span class="pull-left itineraryfonts">
            <s:if test='orderVO.orderModel != null && orderVO.orderItemModelList != null && orderVO.orderItemModelList.size() == orderVO.orderModel.totalNum'>
            	成员信息 </span>
            	<span class="bluearrow  bluedownarrow pull-right"></span>
            </s:if>
            <s:else>
            	添加 
	            <i class="color_orange" id="memberNum"> 
	            <s:if test='orderVO.orderModel != null'><s:property value='orderVO.orderModel.totalNum' /></s:if><s:else>1</s:else>
	            </i> 位成员信息
	            </span>
	            <a href="#" onclick="addMember(this)"><span class="pull-right date" style="position:relative"><span class="glyphicon glyphicon_add glyphicon_size"></span></span>
	            </a> 
            </s:else>
           
            </h4>
          </div>
         <s:if test='orderVO.orderItemModelList != null && orderVO.orderItemModelList.size() > 0'>
          <div  class="panel-collapse collapse in">
            <div class="panel-body table_news">
              <div class="row">
                <div class="col-xs-12 itinerary_show col-sm-12 padding_0">
                  <table class="table table-bordered" border="0" width="100%">
                    <tbody id="item_tbody">
                      <s:iterator value="orderVO.orderItemModelList" var="orderItem" status="countIdx">
                      <tr <s:if test="#orderItem.isAdult">class="adult_tr"</s:if><s:else>class="children_tr"</s:else> >
                        <td  class="light_blue">姓名</td>
                        <td><s:property value="#orderItem.memberName" /><s:if test='order.orderItems.size() > 1'><a onclick="deleteMember(this,'<s:property value="#orderItem.id" />')"><span class="glyphicon glyphicon_delete pull-right "></span></a></s:if><a href="weixin/order/editMember.action?orderVO.orderItemModelList[0].id=<s:property value='#orderItem.id' />"><span class="glyphicon glyphicon_edit pull-right "></span></a></td>
                      </tr>
                      <tr>
                        <td class="light_blue">性别</td>
                        <td><s:property value="getText('gender.' + #orderItem.gender)" /></td>
                      </tr>
                       <tr>
                        <td class="light_blue">年龄</td>
                        <td><s:if test="#orderItem.isAdult">成人</s:if><s:else>儿童</s:else></td>
                      </tr>
                      </s:iterator>
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </s:if>
        </div>
        
       
        <div class="panel panel-default  margin-bottom-10" style="overflow:visible" >
          <s:if test='orderVO.orderModel != null && orderVO.orderItemModelList != null && orderVO.orderItemModelList.size() == orderVO.orderModel.totalNum'>
          <div class="panel-heading collapseDiv" onclick="$(this).next().collapse('toggle')">
            <h4 class="panel-title clearfix"> <a class="accordion-toggle clearfix "><span class="glyphicon glyphicon_linkman glyphicon_size pull-left"></span> <span class="pull-left itineraryfonts">联系人信息</span> <span
																		class="bluearrow  bluedownarrow pull-right"></span></a> </h4>
          </div>
          </s:if>
          
          <s:if test='orderVO.orderModel != null && orderVO.orderItemModelList != null && orderVO.orderItemModelList.size() == orderVO.orderModel.totalNum'>
          <div id="collapse-Three" class="panel-collapse collapse in" >
            <div class="panel-body" >
              <div class="row">
                <div class="col-xs-12 itinerary_show"  >
                </s:if>
                  <form id="orderForm" class="form-horizontal" action="weixin/order/addMember.action" method="get">
                  	<input name="orderVO.orderModel.startingDate" id="startingDate" type="hidden" <s:if test='orderVO.orderModel.goDateString != null'>value="<s:property value='orderVO.orderModel.goDateString' />"</s:if><s:else>value="<s:property value='orderVO.orderModel.defaultDateString' /></s:else> >
                  	<input  name="orderVO.orderModel.adultNum"  type="hidden" value="<s:property value='orderVO.orderModel.adultNum' />">
                  	<input name="orderVO.orderModel.childrenNum"  type="hidden" value="<s:property value='orderVO.orderModel.childrenNum' />">
                  	<input  name="orderVO.orderModel.isShareHouse"  type="hidden" value="<s:if test='orderVO.orderModel.isShareHouse != null'><s:property value='orderVO.orderModel.isShareHouse' /></s:if><s:else>true</s:else>">
                  	<input  name="productVO.productModel.id"  type="hidden" value="<s:property value='productVO.productModel.id' />">
                  	<input  name="orderVO.orderModelid"  type="hidden" value="<s:property value='orderVO.orderModel.id' />">
                  	<s:if test='orderVO.orderModel != null && orderVO.orderItemModelList != null && orderVO.orderItemModelList.size() == orderVO.orderModel.totalNum'>
                    <div class="form-group user_news">
                      <label class="col-sm-2 control-label col-xs-2 padding_right0" for="inputEmail3" style="padding-top:7px">姓名</label>
                      <div class="col-sm-4 col-xs-9">
                        <input type="text" placeholder="请输入姓名" name="orderVO.orderItemModelList[0].memberName" value="<s:property value='orderVO.orderItemModelList[0].memberName' />" class="validate[required] form-control" maxlength="20" data-prompt-position="topLeft:10">
                      </div>
                    </div>
                    
                    <div class="form-group user_news">
	                    <label class="col-sm-2 control-label col-xs-2 padding_right0" for="inputPassword3" style="padding-top:7px">性别</label>
                    	<label class="radio-inline" style="width:30%;text-align:left">
						    <input type="radio" name="orderVO.orderItemModelList[0].gender"  value="male" <s:if test='orderVO.orderItemModelList[0].gender == "male"'> checked </s:if>id="radio_gender_1">男
						</label>
		        	    <label class="radio-inline" style="width:30%;text-align:left">
					         <input type="radio" name="orderVO.orderItemModelList[0].gender" value="female" <s:if test='orderVO.orderItemModelList[0].gender == "female"'> checked </s:if> id="radio_gender_2">女
					    </label>
                    </div>
                    
                    <div class="form-group user_news">
                      <label class="col-sm-2 control-label col-xs-2 padding_right0" for="inputEmail3"  style="padding-top:7px">电话</label>
                      <div class="col-sm-4 col-xs-9">
                        <input type="text" name="orderVO.orderModel.phone" placeholder="请输入电话号码" value="<s:property value='orderVO.orderModel.phone' />" id="inputPhoneNum" class="form-control"  data-prompt-position="topLeft:10">
                      </div>
                    </div>
                   
                    <div class="form-group user_news">
                      <label class="col-sm-2 control-label col-xs-2 padding_right0" for="inputEmail3" style="padding-top:7px">邮箱</label>
                      <div class="col-sm-4 col-xs-9">
                        <input type="text" placeholder="请输入邮箱"  name="orderVO.orderModel.email" value="<s:property value='orderVO.orderModel.email' />" class="form-control" data-prompt-position="topLeft:10">
                      </div>
                    </div>
                    </s:if>
                  </form>
                 <s:if test='orderVO.orderModel != null && orderVO.orderItemModelList != null && orderVO.orderItemModelList.size() == orderVO.orderModel.totalNum'>
                </div>
              </div>
            </div>
          </div>
          </s:if>
        </div>
      </div>
    </div>
  </div>
 
  <div id="buyNow">
	  <div class="row">
	    <div class="col-xs-12 col-sm-12">
	      <div class="total">总计：<span id="totalPrice"><s:if test='orderVO.orderModel != null && orderVO.orderItemModelList != null && orderVO.orderItemModelList.size() == orderVO.orderModel.totalNum'><s:text name="format.number"><s:param value="orderVO.amount"/></s:text></s:if><s:else><s:text name="format.number"><s:param value="productVO.productModel.price"/></s:text></s:else></span></div>
	    </div>
	  </div>
    
	  <div class="row">
	    <div class="col-xs-12 col-sm-12  order_bottombtn padding_10">
	      <a class="btn submit_orders margin_right0" type="button"  <s:if test='orderVO.orderModel != null && orderVO.orderItemModelList != null && orderVO.orderItemModelList.size() == orderVO.orderModel.totalNum'>onclick="buyNow(this)"</s:if><s:else>disabled=disabled style="background:#c6c6c6"</s:else> ><s:if test='orderVO.orderModel != null'>立即购买</s:if><s:else>立即购买(请先添加成员)</s:else></a>
	    </div>
	  </div>
   </div>
  </div>

    <!--电话资询弹出框-->
    <div class=" modal-sm modal_news animated fadeInLeftBig mobileModel"  style="display: none"> 
      <div class="modal-content">
        <div class="modal-header">
          <h4 id="mySmallModalLabel" class="modal-title">提示</h4>
                  <p>数量和成员不对应</p>
        </div>
        <div class="modal-body clearfix modal_btngroup">
           <button class="sure" data-dismiss="modal" type="button" style="width:100%;border-left:0 none"><a>确定</a></button>
        </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
          <!--电话资询弹出框-->
</body>
	<script type="text/javascript">
		var  items;
		var adultPrice="<s:property value='productVO.productModel.price' />";
		var childrenPrice="<s:property value='productVO.productModel.childrenPrice' />";
		
		<s:if test='orderVO.orderModel != null'>
			items=parseInt("<s:property value='orderVO.totalNum' />");
		</s:if>
		Date.prototype.Format = function (fmt) { //author: meizz 
		    var o = {
		        "M+": this.getMonth() + 1, //月份 
		        "d+": this.getDate(), //日 
		        "h+": this.getHours(), //小时 
		        "m+": this.getMinutes(), //分 
		        "s+": this.getSeconds(), //秒 
		        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
		        "S": this.getMilliseconds() //毫秒 
		    };
		    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
		    for (var k in o)
		    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
		    return fmt;
		}
		
		$(function(){
			var dateStr="<s:property value='productVO.productModel.startingDate' />";
			var arrDate=dateStr.split(",");
			var arrDate1=[];
			for(var i=0;i<arrDate.length;i++){
				var d=new Date(arrDate[i]);
				arrDate1.push(d);
			}
			
			if("<s:property value='productVO.productModel.defaultDateString' />"&&"<s:property value='productVO.productModel.defaultDateString' />"){
			$('#startingDate').mobiscroll().calendar({
				theme: 'mobiscroll',
			    lang: 'zh',
			    display: 'bottom',
			    dateFormat:'yy-mm-dd',
			    minDate:new Date("<s:property value='productVO.productModel.defaultDateString' />"),
			    maxDate:new Date("<s:property value='productVO.productModel.maxDateStr' />"),
			    controls: ['calendar'],
			    invalid: ['w0','w1','w2','w3','w4','w5','w6'],
			    valid:arrDate1,
		        onSelect: function (valueText, inst) {
		            var selectedDate = inst.getVal(); // Call the getVal method
		            $("#date_content").empty();
		        	$("#date_content").text(new Date(selectedDate).Format("yyyy-MM-dd"));
		        }
		    });    
			
	       
		  $('#starting_date').click(function(){
		        $('#startingDate').mobiscroll('show'); 
		        return false;
		  });
		    
		}
		    
		 /*  [#if product.beginDate??&&product.endDate??]
			app.datetimePicker({
				startDate:'${ product.beginDate}',
				endDate:'${ product.endDate}',
				selector : '#starting_date',
				minView: 4,
				todayBtn:false,
				pickerPosition: "bottom-right",
				changeEvent:function(ev){
					$("#date_content").empty();
					$("#date_content").text(new Date(ev.date.valueOf()).Format("yyyy-MM-dd"));
					$("#startingDate").val(new Date(ev.date.valueOf()).Format("yyyy-MM-dd"));
				}
			});
			[/#if] */
			
			 $('input:radio').iCheck({
					checkboxClass : 'icheckbox_flat-blue',
					radioClass : 'iradio_flat-blue',
					increaseArea : '100%'
			});
			
			 app.validateEngine('form[id=collapse-One]');
			 app.validateEngine('form[id=orderForm]');
	    });
		
		 function addMember(obj){
        	var adultNum=parseInt($("#adultNum").val());
    	    var childrenNum=parseInt($("#childrenNum").val());
    	    if(!$("#date_content").text()){
    	    	return false;
    	    }
            $("input[name=startingDate]").val($("#date_content").text());
   	    	$("input[name=adultNum]").val(adultNum);
   	    	$("input[name=childrenNum]").val(childrenNum);
   	    	
   	    	var result = $('form[id=collapse-One]').validationEngine('validate');
   	    	if(!result){
   	    		return false;
   	    	}
   	    	if(!$("form[id=orderForm]").serialize()){
   	    		alert("日历控件出错");
   	    		return false;
   	    	}
   	    	$("form[id=orderForm]").submit();
	    }
		 
        function countPrice(){
        	var isShareHouse;
        	var adultNum=$("#adultNum").val();
        	var childrenNum=$("#childrenNum").val();
        	if($("#share_house").hasClass("checked")){
        		isShareHouse="true"
        	}else{
        		isShareHouse="false";
        	}
        	
        	$.ajax({
				url: "weixin/order/countPrice.action?productId=<s:property value='productVO.productModel.id'/>&adultNum="+adultNum+"&childrenNum="+childrenNum+"&isShareHouse="+isShareHouse,
				type: "GET",
				dataType: "json",
				cache: false,
				async:true,
				success: function(data) {
					if(data){
						$("#totalPrice").text(currency(data, true))
					}
				}
			});
        }
        
        function deleteMember(obj,id){
        	 var $this=$(obj);
        	
        	if($(obj).closest('tr').hasClass('adult_tr')){
        		if($(".adult_tr").length==1){
            		alert("必须有一个成人");
            		return;
            	}
        	} 
        	
        	$(obj).attr("onclick","");
        	$.ajax({
				url: "weixin/order/deleteMember.action?id="+id,
				type: "GET",
				dataType: "json",
				cache: false,
				async:true,
				success: function(data) {
					if(data&&data!="null"){
							$this.closest("tr").next().next().remove();
							$this.closest("tr").next().remove();
							$this.closest("tr").remove();
							$("#adultNum").val(data.adultNum);
							$("#childrenNum").val(data.childrenNum);
							var total=data.adultNum+data.childrenNum;
							if(total==1){
								 //$("table tr:first").find("td").eq(1).empty();
								 $("table tr:first").find("td").eq(1).find("a").eq(0).remove();
							}
							countPrice();
					}
				}
			}); 
        }
        
        function addOne(obj){
        	var result = $('form[id=collapse-One]').validationEngine('validate');
   	    	if(!result){
   	    		return false;
   	    	}
        	var $this=$(obj).closest(".row").find("input");
        	var peopleNum=$this.val();
        	var intPeopleNum=parseInt(peopleNum);
        	intPeopleNum++;
        	$this.val(intPeopleNum);
        	var adultNum=parseInt($("#adultNum").val());
    	    var childrenNum=parseInt($("#childrenNum").val());
    	    var totalNum=adultNum+childrenNum;
    	    var $this=$(obj).closest(".row").find("input");
    	    
        	var dbChildrenNum=parseInt($(".children_tr").length);
        	var dbAdultNum=parseInt($(".adult_tr").length);
        	items=dbChildrenNum+dbAdultNum;
        	
    	    if(totalNum==0){
    	    	$("#adultNum").val(1);
    	    	totalNum=1;
    	    }else if(items&&items<totalNum){
    	    	var tep=totalNum-items;
    	    	var html='<h4 class="panel-title clearfix"><span class="glyphicon glyphicon_peoples glyphicon_size pull-left" ></span><span class="pull-left itineraryfonts">添加  <i class="color_orange" id="memberNum"></i> 位成员信息</span><a href="#" onclick="addMember(this)"><span class="pull-right date" style="position:relative"><span class="glyphicon glyphicon_add glyphicon_size"></span></span></a> </h4>'
    	    	$("#member_div").empty();
    	    	$("#member_div").append(html);
    	    	$("#member_div").attr("onclick","");
    	    	totalNum=tep;
    	    }else if(items&&items==totalNum){
    	    	var html='<h4 class="panel-title clearfix"> <a class="accordion-toggle clearfix "><span class="glyphicon glyphicon_linkman glyphicon_size pull-left"></span> <span class="pull-left itineraryfonts">成员信息</span> </a> </h4>'
    	    	$("#member_div").empty();
    	    	$("#member_div").append(html);
    	    	$("#member_div").attr("onclick","$(this).next().collapse('toggle')")
    	    }
        	$("#memberNum").text(totalNum); 
        	countPrice();
        	/* [#if order??]
    		 validateNum();
    	    [/#if] */
        }
        
        function downOne(obj){
        	<s:if test='orderVO.orderModel != null'>
    		 validateNum();
    	    </s:if>
        	var result = $('form[id=collapse-One]').validationEngine('validate');
   	    	if(!result){
   	    		return false;
   	    	}
   	    	
        	var $this=$(obj).closest(".row").find("input");
        	var dbChildrenNum=$(".children_tr").length;
        	var dbAdultNum=$(".adult_tr").length;
        	items=dbChildrenNum+dbAdultNum;
        	
        	if((dbChildrenNum&&dbChildrenNum>=parseInt($("#childrenNum").val()))&&$this.attr("id")=="childrenNum"){
        		return;
        	}
        	if((dbAdultNum&&dbAdultNum>=parseInt($("#adultNum").val()))&&$this.attr("id")=="adultNum"){
        		return;
        	}
        	
        	var peopleNum=$this.val();
        	var intPeopleNum=parseInt(peopleNum);
        	if(intPeopleNum>0){
        		intPeopleNum--;
        		$this.val(intPeopleNum);
        	}
        	
        	var adultNum=parseInt($("#adultNum").val());
    	    var childrenNum=parseInt($("#childrenNum").val());
    	    var totalNum=adultNum+childrenNum;
    	    
    	    if(totalNum==0){
    	    	$("#adultNum").val(1);
    	    	totalNum=1;
    	    }else if(items&&items<totalNum){
    	    	var tep=totalNum-items;
    	    	var html='<h4 class="panel-title clearfix"><span class="glyphicon glyphicon_peoples glyphicon_size pull-left" ></span><span class="pull-left itineraryfonts">添加 <i class="color_orange" id="memberNum"></i> 位成员信息</span><a href="#" onclick="addMember()"><span class="pull-right date" style="position:relative"><span class="glyphicon glyphicon_add glyphicon_size"></span></span></a> </h4>'
    	    	$("#member_div").empty();
    	    	$("#member_div").attr("onclick","");
    	    	$("#member_div").append(html);
    	    	totalNum=tep;
    	    }else if(items&&items==totalNum){
    	    	var html='<h4 class="panel-title clearfix"> <a class="accordion-toggle clearfix "><span class="glyphicon glyphicon_linkman glyphicon_size pull-left"></span> <span class="pull-left itineraryfonts">成员信息</span> </a> </h4>'
    	    	$("#member_div").empty();
    	    	$("#member_div").attr("onclick","$(this).next().collapse('toggle')")
    	    	$("#member_div").append(html);
    	    }
        	$("#memberNum").text(totalNum);
    	    countPrice();
    	    <s:if test='orderVO.orderModel != null'>
   		      validateNum();
   	        </s:if>
        }
        
        function choose(obj,status){
        	var $this=$(obj);
        	var input=$this.find("input");
        	input.parent().addClass('checked');
			if(status==0){
				$this.next().find("input").parent().removeClass('checked');
				$("#agreement").empty();
        		$("#agreement").append("根据实际情况，也有可能实在没法拼房，届时仍需补单房差，但我们将努力不让你多花钱");
        		$("input[name=isShareHouse]").val(true);
        	}else{
        		$this.prev().find("input").parent().removeClass('checked');
        		$("#agreement").empty();
        		$("#agreement").append('需要补单房差 ${product.hoursePrice}元，如需加床或转为三人间请致电：<i><a href="tel:<s:property value='productVO.productModel.phone'/>"><s:property value="productVO.productModel.phone"/></a></i>');
        		$("input[name=isShareHouse]").val(false);
        	}
        	
        	countPrice();
        }
        
    	$(".mobileModel").click(function(){
    		$(".mobileModel").hide();
    	});
    	
    	
    	function checkPhoneNum(){ 
    		var inputPhoneNum = $("#inputPhoneNum").val();
      		var result; 
    		if(inputPhoneNum.trim()=="") {
    	 		
    	 	} else {
    	 		if(typeof(inputPhoneNum)=="undefined")   
    			return false;  
    			if(inputPhoneNum=="" || inputPhoneNum==null){    
    				return false;  
    			}   
    			
    			if(inputPhoneNum.length!=11){   
    				result = "请输入11位手机号码";   
    			}  
    			
    			var myreg = /^(1[3-9]{1}[0-9]{1})\d{8}$/;  
    			if(!myreg.test(inputPhoneNum)){   
    				result = "请输入合法的手机号码"; 
    			}  
    			if(result) return result;
    	 	}
    		
    	}
    	
        function buyNow(obj){
        	$("input[name=phone]").removeClass();
        	$("input[name=phone]").addClass("validate[required,funcCall[checkPhoneNum]] form-control");
        	$("input[name=email]").removeClass();
        	$("input[name=email]").addClass("validate[required, custom[email] form-control");
        	var result = $('form[id=orderForm]').validationEngine('validate');
        	var result1 = $('form[id=collapse-One]').validationEngine('validate');
           	if(!result||!result1){
           		return false;
           	} 
           	<s:if test='orderVO.orderModel != null'>
           	var adultNum=parseInt($("#adultNum").val());
    	    var childrenNum=parseInt($("#childrenNum").val());
    	    $("input[name=adultNum]").val(adultNum);
    	    $("input[name=childrenNum]").val(childrenNum);
    	    items=$(".children_tr").length+$(".adult_tr").length
           	if(items<(adultNum+childrenNum)){
           		$(".mobileModel").show();
           		return false;
           	}
           	</s:if>
           	$(obj).attr("disabled","disabled");
        	window.location.href="weixin/order/buyNow.action?"+$('form[id=orderForm]').serialize()+"&startingDate="+$("input[name=startingDate]").val();
        }
        
        function goUserIndex(){
			window.location.href = "weixin/user/index.html";
		}
        
        
        $(".collapseDiv").click(function(){
			if($(this).find(".bluearrow").hasClass("blueuparrow")){
				$(this).find(".bluearrow").removeClass("blueuparrow").addClass("bluedownarrow");
			}else{
				$(this).find(".bluearrow").removeClass("bluedownarrow").addClass("blueuparrow");
			}
		});
        
        function validateNum(){
        	var dbAdultNum=parseInt("<s:property value='orderVO.orderModel.adultNum' />");
        	var dbChildrenNum=parseInt("<s:property value='orderVO.orderModel.childrenNum' />");
        	var adultNum=parseInt($("#adultNum").val());
    	    var childrenNum=parseInt($("#childrenNum").val());
    	    var total=adultNum+childrenNum;
    	    if((dbAdultNum==adultNum||dbChildrenNum==childrenNum)&&items==total){
    	    	var html='<h4 class="panel-title clearfix"> <a class="accordion-toggle clearfix "><span class="glyphicon glyphicon_linkman glyphicon_size pull-left"></span> <span class="pull-left itineraryfonts">成员信息</span> <span class="bluearrow  bluedownarrow pull-right"></span></a> </h4>'
        	    $("#member_div").empty();
        	    $("#member_div").append(html);
    	    }
        }
	</script>
</html>